package com.yyn.Learning.controller;


import com.yyn.Learning.client.VodClient;
import com.yyn.Learning.entity.EduChapter;
import com.yyn.Learning.entity.EduVideo;
import com.yyn.Learning.service.EduChapterService;
import com.yyn.Learning.service.EduVideoService;
import com.yyn.R;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 课程视频 前端控制器
 * </p>
 *
 * @author yyn
 * @since 2022-11-22
 */
@RestController
@CrossOrigin
@RequestMapping("/Learning/edu-video")
public class EduVideoController {

    @Autowired
    EduVideoService eduVideoService;
    //    注入Vod(接口暴露)
    @Autowired
    private VodClient vodClient;

    @ApiOperation("新增小节")
    @PostMapping("/save")
    public R save(@RequestBody EduVideo eduVideo) {
        eduVideoService.saveVideo(eduVideo);
        return R.success().message("新增成功");

    }

    @ApiOperation("删小节")
//    需要完善 nacos 在删小节时同时删vod服务中的视频
    @DeleteMapping("/remove")
    public R remove(String id) {
//        写在了service中  给chapter来调用
//                这里没用
        eduVideoService.removeTwo(id);
        return null;
    }

    @ApiOperation("改小节")
    @PostMapping("/update")
    public R update(@RequestBody EduVideo eduVideo) {
        eduVideoService.updateVideo(eduVideo);
        return R.success().message("新增成功");

    }

    @ApiOperation("查小节")
    @GetMapping("/getAll")
    public R getAll() {
        eduVideoService.getAllVideo();
        return R.success().message("查询成功");

    }

    @ApiOperation("通过id查")
    @GetMapping("/getOne/{id}")
    public R getOne(@PathVariable String id) {
        eduVideoService.getOneVideo(id);
        return R.success().message("查询成功");

    }

}

